<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ include file="../header.jsp"%>

<div class="content-wrapper" style="font-family: '微软雅黑';">
	<input type="hidden" id="ctx" value="<%=request.getContextPath()%>" />
	<!-- Content Header (Page header) -->
	<section class="content-header">
		<h1>
			${module} <small>Control panel</small>
		</h1>
		<ol class="breadcrumb">
			<li><a href=""><i class="fa fa-dashboard"></i>主页</a></li>
			<li class="active">订单列表</li>
		</ol>
	</section>
	<!-- Main content -->
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<div class="box-header">
						<div>
							<div>
								订单类型： <select type="text" id="otype" >
										<option value="-1">全部</option>
										<option value="1">代办</option>
										<option value="2">代购</option>
										<option value="3">代送</option>
									</select> 
								订单状态：  <select type="text" id="ostatus" > 
											<option value="-1">全部</option>
											<option value="1">呼单中</option>
											<option value="2">代办</option>
											<option value="3">已抢单</option>
											<option value="4">已购买</option>
											<option value="5">已取货</option>
											<option value="6">已办完</option>
											<option value="7">待付款</option>
											<option value="8">待评价</option>
											<option value="9">交易结束</option>
										</select>
								关键字：<input type="text" id="keyCode" /> 
								<input type="button" class="btn btn-success" style="width: 100px;" onclick="search1()" value="查询">
							</div>
						</div>
					</div>
					<!-- /.box-header -->
					<div class="box-body">
						<table id="example" class="display">
							<thead>
								<tr style="background-color: #97CBFF; color: white">
									<th>订单类型</th>
									<th>订单状态</th>
									<th>文字需求</th>
									<th>小费</th>
									<th>发布者</th>
									<th>编辑</th>
								</tr>
							</thead>
						</table>
					</div>
					<!-- /.box-body -->
				</div>
				<!-- /.box -->
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
		<!--  显示下面的分页控件  -->
	</section>
	<!-- /.content -->
</div>
<jsp:include page="../js.jsp" />
<%@ include file="../footer.jsp"%>
<script type="text/javascript">

	var table;
	$(document)
			.ready(
					function() {
						var u = '<c:url value="/orders/edit?orderid="/>';
						table = $('#example').DataTable(
							{
								"pagingType" : "simple_numbers",//设置分页控件的模式  
								searching : false,//屏蔽datatales的查询框  
								aLengthMenu : [ 10, 50, 100 ],//设置一页展示10条记录  
								"bLengthChange" : true,//屏蔽tables的一页展示多少条记录的下拉列表  
								"oLanguage" : { //对表格国际化  
									"sLengthMenu" : "每页显示 _MENU_条",
									"sZeroRecords" : "没有找到符合条件的数据",
									//  "sProcessing": "&lt;img src=’./loading.gif’ /&gt;",    
									"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
									"sInfoEmpty" : "木有记录",
									"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
									"sSearch" : "搜索：",
									"oPaginate" : {
										"sFirst" : "首页",
										"sPrevious" : "前一页",
										"sNext" : "后一页",
										"sLast" : "尾页"
	
									}
								},
								"processing" : true, //打开数据加载时的等待效果  
								"serverSide" : true,//打开后台分页  
								"ajax" : {
									"url" : '<c:url value="/orders/order/data"/>',
									"dataSrc" : "aaData",
									"type": "POST",
									"data" : function(d) {
										var otype = $('#otype').val();
										var ostatus = $('#ostatus').val();
										var keyCode = $('#keyCode').val();
										//添加额外的参数传给服务器  
										d.otype = otype;
										d.ostatus = ostatus;
										d.keyCode = keyCode;
									}
	
								},
								"columns" : [
										{
											"data" :function(obj) {
												if (obj.ordertypeid == 1) {
													return "代办";
												} else if (obj.ordertypeid == 2) {
													return "代购";
												} else if(obj.ordertypeid==3){
													return "代送";
												}
											}
										},
										{
											"data" : function(obj) {
												if (obj.status == 1) {
													return "呼单中";
												} else if (obj.status == 2) {
													return "已抢单";
												} else if(obj.status==3){
													return "已接单";
												}else if(obj.status==4){
													return "已购买";
												}else if(obj.status==5){
													return "已取货";
												}else if(obj.status==6){
													return "已办完";
												}else if(obj.status==7){
													return "待付款";
												}else if(obj.status==8){
													return "待评价";
												}else if(obj.status==9){
													return "交易结束";
												}
											}
										},
										{
											"data" :function(obj) {
												if(obj.descption){
													return obj.descption;
												}
												return "";
											}
										},
										{
											"data" :  function(obj) {
												if(obj.tip){
													return obj.tip;
												}
												return "";
											}
										},
										{
											"data" : function(obj) {
												if(obj.nickname){
													return obj.nickname;
												}
												return "";
											}
										},
										{
											"data" : function(obj) {
												if(obj.orderid){
													return "<a href='"+u+obj.orderid+"'>编辑</a>&nbsp;&nbsp;&nbsp;"+
													"<a href='javascript:void(0)' onclick='deleteAdvert("+obj.orderid+")'>删除</a>";
												}
												return "";
											}
										} ]
	
							});
					});

	function search1() {
		table.ajax.reload();
	}

	function deleteAdvert(id){
		var u = '<c:url value="/advert/delete?advertid="/>';
		swal({   
			title: "确定删除?",   
			text: "删除后将无法回复!",   
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "确定删除!",   
			cancelButtonText: "取消!",   
			closeOnConfirm: false,   
			closeOnCancel: true }, 
			function(isConfirm){   
				if (isConfirm) {
					$.post(u+id,{},function(data){
						if(data.code==0){
							table.ajax.reload();
							swal("已删除!", "该广告已成功删除", "success");  
						}
					},"json");
				} 
			});
	}
	
	function auditPass(id) {
		var localhostPaht = $("#ctx").val();
		// 调用审核方法
		$.post(localhostPaht + "/broker/withdraw/allow", {
			withdrawids : id
		}, function(data) {
			table.ajax.reload();
		});
	}
</script>
</body>
</html>





